<?php

namespace app\controller;

use app\BaseController;
use app\Request;
use app\services\AuthService;
use app\services\DealDataService;
use app\utils\AppRespUtil;
use app\utils\TimeUtil;

class Auth extends BaseController
{
    /**
     * 登录
     *
     * @param Request $request
     * @return string
     */
    public function login(Request $request)
    {
        $params = $request->only(['username', 'password'], 'post');
        $this->validate(
            $params,
            [
                'username' => 'require',
                'password' => 'require',
            ],
            [
                'username.require' => '请输入用户名',
                'password.require' => '请输入密码',
            ]
        );

        return AppRespUtil::success((new AuthService([], $params))->login());
    }

    public function getToken()
    {
        return AppRespUtil::success(['token' => 'ef2d646e2d595712c5735ffcefe60490', 'is_fresh' => 1]);
    }

    public function test()
    {
        return AppRespUtil::success(DealDataService::dealBcWaitData());
    }
}